#include "widget.h"
#include "ui_widget.h"
#include"QIcon"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QIcon left(":/left.png");
    QIcon s(":/people.png");
    QIcon up(":/up.png");
    QIcon down(":/down.png");
    QIcon right(":/right.png");
    ui->people->setIcon(s);
    ui->people->setIconSize(QSize(90,90));
    ui->up->setIcon(up);
    ui->up->setIconSize(QSize(90,90));
    ui->down->setIcon(down);
    ui->down->setIconSize(QSize(90,90));
    ui->left->setIcon(left);
    ui->left->setIconSize(QSize(90,90));
    ui->right->setIcon(right);
    ui->right->setIconSize(QSize(90,90));
    ui->up->setShortcut(Qt::Key_W);
    ui->down->setShortcut(Qt::Key_S);
    ui->left->setShortcut(Qt::Key_A);
    ui->right->setShortcut(Qt::Key_D);
    ui->up->setAutoRepeat(true);
    ui->down->setAutoRepeat(true);
    ui->left->setAutoRepeat(true);
    ui->right->setAutoRepeat(true);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_up_clicked()
{
    QRect as=ui->people->geometry();
    ui->people->setGeometry(as.x(),as.y()-10,as.width(),as.height());
}

void Widget::on_down_clicked()
{
    QRect as=ui->people->geometry();
    ui->people->setGeometry(as.x(),as.y()+10,as.width(),as.height());
}

void Widget::on_left_clicked()
{
    QRect as=ui->people->geometry();
    ui->people->setGeometry(as.x()-10,as.y(),as.width(),as.height());
}

void Widget::on_right_clicked()
{
    QRect as=ui->people->geometry();
    ui->people->setGeometry(as.x()+10,as.y(),as.width(),as.height());
}
